﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace Sodu.Util
{

    public delegate void PopupClosedHandler();
    public delegate void CloseEventHandler();
    public class ShowDialog
    {

        public Popup PopupDialog = new Popup();
        public event PopupClosedHandler PopupClosed;
        public ShowDialog()
        {
            PopupDialog.Closed += PopupDialog_Closed;
        }

        void PopupDialog_Closed(object sender, object e)
        {
            if (PopupClosed != null)
            {
                PopupClosed();
            }
        }
        public void SetContent(Control content, double parentHeight, double parentWidth)
        {
            if (content == null) return;

            this.PopupDialog.Child = content;
           
            this.PopupDialog.HorizontalOffset = (parentWidth - content.Width) / 2; ;
            this.PopupDialog.VerticalOffset = 50;
        }

        public void Show()
        {
            if (this.PopupDialog.IsOpen == false)
            {
                this.PopupDialog.IsOpen = true;
            }
        }

        public void Close()
        {
            if (this.PopupDialog.IsOpen == true)
            {
                this.PopupDialog.IsOpen = false;
            }
        }



    }
}
